<%--
  User: Sujan
  Date: Apr 13, 2007
  Time: 2:53:25 PM
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<%@ page import="com.scalar.chiptrack.commons.Constants,
                 com.scalar.chiptrack.utils.ConfigManager"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/creditNoteAction.do" />
<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet"></HEAD>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>

<SCRIPT language="JavaScript">
    window.onload = init;
    function init()
    {
        qs_1 = new QuickSearch(document.creditNoteForm.customerShippingId, document.creditNoteForm.qs1, false);
    }
    function printView( assmReleaseId )
    {
        newWindow = window.open ('<%=chipTracContext%>/assmRelease.do?action=printerFriendly&assmReleaseId='+assmReleaseId,'printerFreindlyPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=800,height=550,resizable=yes');
    }
    function reset()
    {
        document.creditNoteForm.reset();
        qs_1.resetQuickSearchCntrl();
    }
    function loadSearchValues(changedField)
    {
        var form =  document.creditNoteForm;
        if ( changedField == 'customer' )
        {
            form.salesOrderId.value = 0;
        }
        /*else //salesOrder is changed
        {

        } */
        form.action = "<%=chipTracContext%>/creditNoteAction.do?action=<%=Constants.ACTION_SEARCH_NEW%>"
        form.submit();
    }
    function submitPage()
    {
        var form =  document.creditNoteForm;
        if ( validateForm() )
        {
            form.action = "<%=chipTracContext%>/creditNoteAction.do?action=<%=Constants.ACTION_NEW%>"
            form.submit();
        }
    }
    function validateForm()
    {
        var form =  document.creditNoteForm;
        var pa = document.getElementById( "errors" );
        pa.innerHTML = "";
        var errs = "";

        var customerShippingId = form.customerShippingId.value;
        if ( customerShippingId <= 0 )
        {
            errs += "<li>Please select Packing Slip</li>"
        }

        var noteType = form.noteType.value;
        if ( noteType <= 0 )
        {
            errs += "<li>Please select Is Credit/Debit</li>"
        }
        if ( errs != "" )
        {
            pa.innerHTML = errs;
            return false;
        }
        return true;
    }
</SCRIPT>

<BODY bgColor="#ffffff" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
    <TR>
	    <TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
	    <!-- Side Navigation start -->
	    <%@include file="/jsp/finance/finance_menu.jsp" %>
	    <!-- end of the side navigations -->
        </TD>
	    <TD bgcolor="#ffffff"><IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
	    <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
	    <TD valign="top" width="100%"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
	    <BR>
        <html:form action="/creditNoteAction.do" name="creditNoteForm" type="com.scalar.chiptrack.finance.creditNote.forms.CreditNoteForm" onsubmit="return false;">
		    <TABLE width="95%" align="right" cellpadding="2" cellspacing="2" border="0">
			    <TR><TD colspan="4" class="NArialW" align="center">New Credit/Debit Note</TD></TR>
                <TR><TD colspan='4' align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'></font></TD></TR>
			    <TR><TD colspan='4' class="NArialL"><chiptrack:errors styleClass="NArialL"/></TD></TR>
			    <TR><TD colspan='4' class="NArialL"><chiptrack:info styleClass="NArialL"/></TD></TR>
			    <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
                <tr>
                    <td class="NArialL">
                        Customer:
                    </td>
                    <td class="NArialL">
                        <html:select name="creditNoteForm" property="customerId"  styleClass="txfield" onchange="loadSearchValues('customer')">
                            <logic:present name="customers">
                                <html:options collection="customers" property="value" labelProperty="label"/>
                            </logic:present>
                        </html:select>
                    </td>
                    <td class="NArialL">
                        SO Number:
                    </td>
                    <td class="NArialL">
                        <html:select name="creditNoteForm" property="salesOrderId" styleClass="txfield" onchange="loadSearchValues('salesOrder')">
                            <html:option value="0"> Select SO No</html:option>
                            <logic:present name="salesOrderNumbers">
                                <html:options collection="salesOrderNumbers" property="value" labelProperty="label"/>
                            </logic:present>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td class="NArialL">
                        Is Credit/Debit:&nbsp;<font color=red>*</font>
                    </td>
                    <td class="NArialL">
                        <nested:select property="noteType"  styleClass="txfield" >
                            <html:option value="0"> Select Note Type</html:option>
                            <html:option value="Credit"/>
                            <html:option value="Debit"/>
                        </nested:select>
                    </td>
                    <td class="NArialL" nowrap>
                        Quick Search Packing Slip:
                    </td>
                    <td class="NArialL">
                        <input type="text" name="qs1" class="txfield" size='16' onkeyup='quickSearch(qs_1)'/>
                    </td>                    
                </tr>
                <tr>
                    <td class="NArialL" colspan="2">
                        <nested:checkbox property="isUnits" styleClass="txfield" styleId="isUnits"/>&nbsp;<label for="isUnits">Consider Units</label>
                    </td>
                    
                    <td class="NArialL">Select Packing Slip:&nbsp;<font color=red>*</font></td>
                    <td class="NArialL">
                        <html:select name="creditNoteForm" property="customerShippingId" styleClass="txfield" >
                            <html:option value="0">Select PS Label</html:option>
                            <logic:present name="packingSlipLabels">
                                <html:options collection="packingSlipLabels" property="value" labelProperty="label"/>
                            </logic:present>
                        </html:select>
                    </td>
                </tr>
                <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='10'></TD></TR>
			    <tr>
				    <td colspan="5" align="center">
                        <a href="javascript:submitPage()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Search Credit Note';return true" onmouseout="window.status='';return true" title="Click here to Search Credit Note" alt=""></a>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
				        <a href="javascript:reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>
				    </td>
			    </tr>
			    <TR><TD colspan='4'><IMG src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height='20'></TD></TR>
		    </TABLE>
	    </html:form>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->

</BODY>
</HTML>